import { IPSRawItem } from './ipsraw-item';
import { IPSRawItemBase } from './ipsraw-item-base';
import { IPSRawItemParam } from './ipsraw-item-param';
import { IPSSysCss } from '../res/ipssys-css';
import { IPSSysImage } from '../res/ipssys-image';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSRawItemImpl extends PSModelObjectImpl implements IPSRawItem, IPSRawItemBase {
  get codeName(): string {
    return this.M.codeName;
  }

  get contentType(): string {
    return this.M.contentType;
  }

  get cssStyle(): string {
    return this.M.cssStyle;
  }

  get dynaClass(): string {
    return this.M.dynaClass;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get htmlContent(): string {
    return this.M.htmlContent;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psrawitemparams: IPSRawItemParam[] | null = null;

  getPSRawItemParams(): IPSRawItemParam[] | null {
    if (this.psrawitemparams == null) {
      this.psrawitemparams = this.fillChildListModel(this.M.getPSRawItemParams, 'control.IPSRawItemParam') as IPSRawItemParam[];
    }
    return this.psrawitemparams;
  }

  get psRawItemParams(): IPSRawItemParam[] | null {
    return this.getPSRawItemParams();
  }

  findPSRawItemParam(objKey: any): IPSRawItemParam | null {
    return this.getPSModel5('control.IPSRawItemParam', this.getPSRawItemParams(), objKey) as IPSRawItemParam;
  }

  protected pssyscss: IPSSysCss | null = null;

  getPSSysCss(): IPSSysCss | null {
    if (this.pssyscss != null) return this.pssyscss;
    const value = this.M.getPSSysCss;
    if (value == null) {
      return null;
    }
    this.pssyscss = this.getPSModel4('res.IPSSysCss', value, 'getPSSysCss') as IPSSysCss;
    return this.pssyscss;
  }

  get psSysCss(): IPSSysCss | null {
    return this.getPSSysCss();
  }

  getPSSysCssMust(): IPSSysCss {
    const value = this.getPSSysCss();
    if (value == null) {
      throw new Error('未指定系统样式表');
    }
    return value;
  }

  protected pssysimage: IPSSysImage | null = null;

  getPSSysImage(): IPSSysImage | null {
    if (this.pssysimage != null) return this.pssysimage;
    const value = this.M.getPSSysImage;
    if (value == null) {
      return null;
    }
    this.pssysimage = this.getPSModel4('res.IPSSysImage', value, 'getPSSysImage') as IPSSysImage;
    return this.pssysimage;
  }

  get psSysImage(): IPSSysImage | null {
    return this.getPSSysImage();
  }

  getPSSysImageMust(): IPSSysImage {
    const value = this.getPSSysImage();
    if (value == null) {
      throw new Error('未指定图片对象');
    }
    return value;
  }

  get predefinedType(): string {
    return this.M.predefinedType;
  }

  get rawContent(): string {
    return this.M.rawContent;
  }

  get rawItemHeight(): number {
    return this.M.rawItemHeight != null ? this.M.rawItemHeight : 0.0;
  }

  get rawItemWidth(): number {
    return this.M.rawItemWidth != null ? this.M.rawItemWidth : 0.0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get templateMode(): boolean {
    return this.M.templateMode != null ? this.M.templateMode : false;
  }

  get cls(): string {
    return 'PSRawItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSRawItem' || cls == 'control.IPSRawItemBase') return true;
    return super.instanceof(cls);
  }
}
